#include <iostream>
using namespace std;

const int N = 20000 + 10;
int primes[N], cnt;
bool st[N];

void get_prime(int x) {
    for (int i = 2; i <= x; i++) {
        if (!st[i]) {
            primes[cnt++] = i;
            for (int j = i + i; j <= x; j += i) {
                st[j] = true;
            }
        }
    }
}

int main() {
    int n = 20000;
    get_prime(n);

    for (int i = 0; i < cnt; i++) {
        cout << primes[i] << " ";
        if ((i + 1) % 5 == 0) {
            cout << endl;
        }
    }

    return 0;
}

